package com.hymall.service.wx;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hymall.bean.MarketTopic;
import com.hymall.bean.MarketTopicExample;
import com.hymall.bean.common.BasePageInfo;
import com.hymall.bean.common.CommonData;
import com.hymall.mapper.MarketTopicMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 赵思源
 * @since 2022/07/20 20:21
 * 专题活动小程序的接口实现
 */
@Service
public class WxTopicServiceImpl implements WxTopicService {

    @Autowired
    MarketTopicMapper marketTopicMapper;

    /**
     * 显示专题精选列表
     * @author Zhaosiyuan
     * @date 2022/7/20 0020 20:46
     */
    @Override
    public CommonData queryTopicList(BasePageInfo info) {
        PageHelper.startPage(info.getPage(), info.getLimit());
        MarketTopicExample marketTopicExample = new MarketTopicExample();
        List<MarketTopic> marketTopics = marketTopicMapper.selectByExample(marketTopicExample);
        PageInfo<MarketTopic> pageInfo = new PageInfo<>(marketTopics);
        return CommonData.data(pageInfo);
    }

    @Override
    public MarketTopic selectTopicById(Integer id) {
        MarketTopic marketTopic = marketTopicMapper.selectByPrimaryKey(id);
        return marketTopic;
    }
}
